//Monday, November 02 2009
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>

using namespace std;

class SubrectanglesOfTable
{
public:
	vector<long long> getQuantity(vector <string> table)
	{
		vector<string> card;
		vector<long long> ret(26,0);
		int N = table.size();
		int W = table[0].size();
		for(int i=0; i<N; i++)
			card.push_back(table[i]+table[i]);
		for(int i=0; i<N; i++)
			card.push_back(table[i]+table[i]);
		for(int i=0; i<2*N; i++)
			for(int j=0; j<2*W; j++)
				ret[card[i][j]-'A'] += (i+1)*(2*N-i)*(j+1)*(2*W-j);
		return ret;
	}
};
